package com.jeasonzhao.web;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public abstract class EnvelopeTag extends ControlSupportTag
{
    private static final long serialVersionUID = 1L;
    public EnvelopeTag()
    {
        super();
    }

    public EnvelopeTag(String tagName)
    {
        super(tagName);
    }

    public final int doStartTag()
        throws JspException
    {
        try
        {
            //checkId();
            beforeTag();
            this.writeTagBeginText();
            afterStartTag();
        }
        catch(Exception ex)
        {
            this.write(ServletHelper.exception2HTML(ex,this.getClass()));
        }
        return TagSupport.EVAL_BODY_INCLUDE;
    }

    public final int doEndTag()
        throws JspException
    {
        try
        {
            beforeEndTag();
            this.writeTagEndText();
            afterTag();
        }
        catch(Exception ex)
        {
            this.write(ServletHelper.exception2HTML(ex,this.getClass()));
        }
        this.setId(null);
        this.clearAttributes();
        return TagSupport.EVAL_PAGE;
    }

    protected void afterTag()
        throws Exception
    {

    }

    protected void afterStartTag()
        throws Exception
    {

    }

    protected void beforeEndTag()
        throws Exception
    {

    }

    protected void beforeTag()
        throws Exception
    {

    }

}
